package com.mhkj.revise.function.controller;

import java.text.ParseException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mhkj.revise.function.service.FunctionPlanNodeService;
import com.mhkj.revise.plan.entity.PlanNode;
import com.mics.core.common.componet.JsonHandler;
import com.mics.core.common.componet.Pagination;
import com.mics.core.common.componet.ResponseMessage;
import com.mics.core.system.base.controller.BaseController;

/**
 * 职能计划节点
 * @author mics
 * @date 2018年8月29日
 * @version 1.0
 */
@Controller
@RequestMapping("/functionPlanNode")
public class FunctionPlanNodeController extends BaseController<PlanNode>{
	@Resource
	private FunctionPlanNodeService functionPlanNodeService;
	@Resource
	private JsonHandler jsonHandler;
	
	@RequestMapping("/listByPage")
	@ResponseBody
	public void listByPage(HttpServletResponse response, PlanNode planNode, int pageIndex, int pageSize) {
		Pagination<PlanNode> pagination = functionPlanNodeService.listByPage(planNode, pageIndex, pageSize);
		jsonHandler.sendJsonString(response, true, "获取数据成功", pagination,
				new String[]{"id","NO","plan.functionOffice.name","nodeName","nodeProperty.value","completeStandard","deadline","deadlineDesc","beginDate","endDate","remark","companyName","officeName","postName"},
				"id","NO","functionOfficeValue","nodeName","nodeProperty","completeStandard","deadline","deadlineDesc","beginDate","endDate","remark","companyName","officeName","postName");
	}

	/**
	 * 修改
	 * @author mics
	 * @date 2018年8月30日
	 * @version 1.0
	 * @throws ParseException 
	 */
	@RequestMapping("/update")
	@ResponseBody
	public ResponseMessage update(HttpServletResponse response, @RequestParam("ids[]")long[] ids,@RequestParam("beginDates[]")String[] beginDates,@RequestParam("endDates[]")String[] endDates) throws ParseException{
		if(ids != null){
			functionPlanNodeService.update(ids,beginDates,endDates);
		}
		
		return ResponseMessage.createMessage(true, "修改时间成功");
		
	}
	
	
}
